<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
	</head>

	<body>
		<script>
			let str = window.prompt('请输入一串字符');
			let reg = /\d+/;
			let flag = true;
			if (str != null && str != '') {
				for (let i in str) {

					if (reg.test(str[i])) {

					} else {
						flag = false;
					}
				}

				if (flag) {
					console.log('是全数字');
				} else {
					console.log('不是全数字');
				}
			} else {
				console.log('您输入了空字符串不能判断');
			}
			// let str = window.prompt('请输入一串字符');
			// let flag = true;
			// for(let i in str){
			//     if(isNaN(str[i])){
			//         flag = false;
			//     }
			// }
			// if(flag){
			//     console.log('是全数字');
			// }else{
			//     console.log('不是全数字');
			// }
		</script>
	</body>

</html>
